package com.extremelylargepackage;

import com.extremelylargepackage.SchmupView.EngineType;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

public class SchmupActivity extends Activity 
{
	private SchmupView _view;

    @Override
	public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        DisplayMetrics dm = new DisplayMetrics();
        this.getWindowManager().getDefaultDisplay().getMetrics(dm);
        GameResources.SCREEN_WIDTH = dm.widthPixels;
        GameResources.SCREEN_HEIGHT = dm.heightPixels;
        GameResources.SCREEN_DENSITY = dm.densityDpi;
        Log.d("width", ""+dm.widthPixels);
        Log.d("height", ""+dm.heightPixels);
        GameResources.setAssets(getAssets());
        GameResources.setContext(this);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setContentView(R.layout.menu);
        _view = (SchmupView) findViewById(R.id.menu);
        _view.getThread().loadResources();
        _view.getThread().startEngine(EngineType.menu, false);
    }
    
    @Override
	public void onConfigurationChanged(Configuration newConfig) 
    {
        super.onConfigurationChanged(newConfig);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    
    @Override
    public void onPause()
    {
    	super.onPause();
    	_view.getThread().pauseGame();
    	_view.getThread().setVisible(false);
    }
    
    @Override
    public void onResume()
    {
    	super.onResume();
    	_view.getThread().resumeGame();
    	_view.getThread().setVisible(true);
    }
    
    @Override
    public void onStop()
    {
    	super.onStop();
    	_view.getThread().pauseGame();
    }
}